package ${tablePath}.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import entity.io.gitee.xiaouyudeguang.common.BaseEntity;
import typeHandler.io.gitee.xiaouyudeguang.common.BigDecimalTypeHandler;
import lombok.*;

import javax.persistence.*;
import java.time.LocalDateTime;

 /**
  * ${table.comment}
  * @author ${author}
  * @since ${dateTime}
  */
@Data
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName(autoResultMap = true)
@EqualsAndHashCode(callSuper = true)
@Table(name = "${table.tableName}", indexes = {})
public class ${table.className} extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @Column(nullable = false, columnDefinition = "varchar(50)  comment '应用id'")
    private String appId;

    @Column(nullable = true, columnDefinition = "varchar(50)  comment '租户id'")
    private String tenantId;

    @Column(nullable = true, columnDefinition = "varchar(50)  comment '客户id'")
    private String customId;

    @Column(nullable = false, columnDefinition = "varchar(50)  comment '${table.comment}id'")
    private String ${table.entityName}Id;
    <#list table.columns as column>
    <#if column.fieldName != "id" && column.fieldName != "creator" && column.fieldName != "modifier"
             && column.fieldName != "created" && column.fieldName != "modified" && column.fieldName != "status"
             && column.fieldName != "extension">

    <#if column.columnType = "datetime">
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    </#if>
    <#if column.columnType = "double(15,2)">
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    @TableField(typeHandler = BigDecimalTypeHandler.class)
    </#if>
    @Column(nullable = true, columnDefinition = "${column.columnType}  comment '${column.comment}'")
    protected ${(column.javaType)} ${column.fieldName};
    </#if>
    </#list>

    @JsonIgnore
    @Column(columnDefinition = "comment '状态'")
    protected Long status;
}